#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-12-09 10:16 上午
# @Author  : yangdy
# @File    : 2020-12-09.2
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def numOfSubarrays(self, arr: List[int]) -> int:
        if not arr:
            return 0
        u = 10 ** 9 + 7
        n1 = [[arr[0] % 2, 1-arr[0] % 2]]
        for i in range(1, len(arr)):
            p = arr[i] % 2
            x = (n1[-1][1] * p + n1[-1][0] * (1 - p) + p) % u
            y = (n1[-1][0] * p + n1[-1][1] * (1 - p) + (1 - p)) % u
            n1.append([x, y])
        return sum(map(lambda q: q[0], n1))


questions = [
    ([1, 3, 5],),
    ([2, 4, 6],),
    ([1, 2, 3, 4, 5, 6, 7],),
    ([100, 100, 99, 99],),
    ([7],),
]

work(questions, lambda q: Solution().numOfSubarrays(q[0]))

